#include<stdio.h>
// #include <windows.h>
#define RESET   "\033[0m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
//得到两个数字和操作符然后如果是‘+’，就加法打印并且询问是否进行乘法，是填入Y或y就进行输入N或n退出打印完成
// void setColor(unsigned short foreColor) {
//     HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
//     SetConsoleTextAttribute(hConsole, foreColor);
// }
int main()
{
    double number1 = 0;
    double number2 = 0;
    char operation = 0;

    loop_start:
    printf("Please an operation expression. just like this:1 + 1\n");
    scanf("%lf %c %lf",&number1,&operation,&number2);

    switch(operation)
    {
        case '+':
        printf("=%.2lf\n",number1 + number2);
        break;
        case '-':
        printf("=%.2lf\n",number1 - number2);
        break;
        case '*':
        
        printf("=%.2lf\n",number1 * number2);
        break;
        case '/':
        if(number2 == 0){
        printf("Error:Divisor cannot be 0. Plaese try again\n");
        goto loop_start;
        }
        else{
        printf("=%.2lf\n",number1 / number2);
        }
        break;
        case '%':
        if(number2 == 0)
       {
        //  setColor(FOREGROUND_RED);
         printf(RED"Error: Divisor cannot be 0. Please try again"RESET"\n");
         goto loop_start;
       }
        else{
           printf("=%.ld\n",(long)number1 % (long)number2);
        }
        break;
        default:
        printf("Invalid operation!Plese try again.");
        goto loop_start;
        
    }

    return 0;
}